/**
 * Created by NickNi on 2022/4/16.
 */
import axios from 'axios';
import { get, post } from './tools';
import * as config from './config';

// export const getBbcNews = () => get({ url: config.NEWS_BBC });

export const npmDependencies = () =>
    axios
        .get('./npm.json')
        .then((res) => res.data)
        .catch((err) => console.log(err));

export const weibo = () =>
    axios
        .get('./weibo.json')
        .then((res) => res.data)
        .catch((err) => console.log(err));

// export const gitOauthLogin = () =>
//     get({
//         url: `${config.GIT_OAUTH}/authorize?client_id=792cdcd244e98dcd2dee&redirect_uri=http://localhost:3006/&scope=user&state=reactAdmin`,
//     });
// export const gitOauthToken = (code: string) =>
//     post({
//         url: `https://cors-anywhere.herokuapp.com/${config.GIT_OAUTH}/access_token`,
//         data: {
//             client_id: '792cdcd244e98dcd2dee',
//             client_secret: '81c4ff9df390d482b7c8b214a55cf24bf1f53059',
//             redirect_uri: 'http://localhost:3006/',
//             state: 'reactAdmin',
//             code,
//         },
//     });
// {headers: {Accept: 'application/json'}}
// export const gitOauthInfo = (access_token: string) =>
//     get({ url: `${config.GIT_USER}access_token=${access_token}` });

// easy-mock数据交互
const axiosConfig = {
    headers: {
        'Content-Type': 'application/json;charset=UTF-8',
    },
};
// 管理员权限获取
export const admin = () => get({ url: config.MOCK_AUTH_ADMIN });
// 访问权限获取
export const guest = () => get({ url: config.MOCK_AUTH_VISITOR });
/** 获取服务端菜单 */
export const fetchMenu = () => get({ url: config.MOCK_MENU });

/** 获取DashBosrd数据 */
export const getDashBosrdData = (data: Object) =>
    post({
        url: config.DashBosrdApi,
        data: data,
        config: axiosConfig,
    });
/** 查询账号角色 */
export const getUserPermission = (data: Object) =>
    post({
        url: config.UserPermissionApi,
        data: data,
    });
/** 查询账号列表 */
export const getAccountRoleList = (data: Object) =>
    post({
        url: config.AccountRoleListApi,
        data: data,
    });
/** 账号状态设置 */
export const setAccountStatus = (data: Object) =>
    post({
        url: config.AccountStatusApi,
        data: data,
    });
/** 开关列表 */
export const getSwitchList = (data: Object) =>
    post({
        url: config.SwitchApi,
        data: data,
    });
/** 开关设置 */
export const setSwitch = (data: Object) =>
    post({
        url: config.SetSwitchApi,
        data: data,
    });
/** 日志搜索 */
export const queryLogList = (data: Object) =>
    post({
        url: config.QueryLogApi,
        data: data,
    });
/** 获取源文件数据 */
export const queryFileData = (data: Object) =>
    post({
        url: config.QueryFileApi,
        data: data,
    });
/** 获取源文件数据 */
export const getSettingList = (data: Object) =>
    post({
        url: config.QuerySettingListApi,
        data: data,
    });

/** 获取源文件数据 */
export const updateConfigData = (data: Object) =>
    post({
        url: config.UpdateConfigApi,
        data: data,
    });

/** 获取源文件数据 */
export const delConfigData = (data: Object) =>
    post({
        url: config.DelConfigApi,
        data: data,
    });
